﻿namespace WMS6.Web.Billing
{
    using System;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using WMS6.Web;
    using WMS6.Web.BaseInfoDetailServiceRef;

    public class RateDetail : BasePage
    {
        protected Button btnCancel;
        protected Button btnSave;
        protected CheckBox chkIsActive;
        protected DropDownList ddlBillingObject;
        protected DropDownList ddlCarryMode;
        protected DropDownList ddlChargeMode;
        protected DropDownList ddlChargeUnit;
        protected DropDownList ddlDescr;
        protected DropDownList ddlDistMatchedMode;
        protected DropDownList ddlDueFromTo;
        protected DropDownList ddlRateType;
        protected HtmlForm F9053;
        protected HtmlInputHidden hdnFlag;
        protected HtmlInputHidden hdnFrom;
        protected HtmlInputHidden hdnLineID;
        protected HtmlInputHidden hdnRateID;
        protected HtmlHead Head1;
        protected HtmlImage img2;
        protected HtmlImage imgOwnerID;
        protected Label Label1;
        protected Label Label2;
        protected Label lblAreaDetail;
        protected Label lblBillingEntity;
        protected Label lblBillingObject;
        protected Label lblCarryMode;
        protected Label lblChargeInvocation;
        protected Label lblChargeMode;
        protected Label lblChargePerUnit;
        protected Label lblChargeUnit;
        protected Label lblCostingUnit;
        protected Label lblCostInvocation;
        protected Label lblCostPerUnit;
        protected Label lblCostRate;
        protected Label lblCSDiscount;
        protected Label lblCuc01;
        protected Label lblCuc010;
        protected Label lblCuc02;
        protected Label lblCuc03;
        protected Label lblCuc04;
        protected Label lblCuc05;
        protected Label lblCuc06;
        protected Label lblCuc07;
        protected Label lblCuc08;
        protected Label lblCuc09;
        protected Label lblDescr;
        protected Label lblDistMatchedMode;
        protected Label lblDueFromTo;
        protected Label lblEADiscount;
        protected Label lblFixedRate;
        protected Label lblFrom;
        protected Label lblFrom1;
        protected Label lblGeneralLedgerID;
        protected Label lblIPDiscount;
        protected Label lblMaxCharge;
        protected Label lblMinCharge;
        protected Label lblMsg;
        protected Label lblPLDiscount;
        protected Label lblPNN;
        protected Label lblRate;
        protected Label lblRateType;
        protected Label lblRemark;
        protected Label lblStc01;
        protected Label lblStc010;
        protected Label lblStc02;
        protected Label lblStc03;
        protected Label lblStc04;
        protected Label lblStc05;
        protected Label lblStc06;
        protected Label lblStc07;
        protected Label lblStc08;
        protected Label lblStc09;
        protected Label lblTaxGroupID;
        protected Label lblTo;
        protected Label lblTo1;
        protected Label lblUdf04;
        protected Label lblUdf09;
        protected Label lblUdf1;
        protected Label lblUdf10;
        protected Label lblUdf2;
        protected Label lblUdf3;
        protected Label lblUdf5;
        protected Label lblUdf6;
        protected Label lblUdf7;
        protected Label lblUdf8;
        protected HtmlLink mycss;
        protected Label one1;
        protected Label one2;
        protected ScriptManager ScriptManager1;
        protected TextBox txtBillingEntity;
        protected TextBox txtChargeInvocation;
        protected TextBox txtChargePerUnit;
        protected TextBox txtCostingUnit;
        protected TextBox txtCostInvocation;
        protected TextBox txtCostPerUnit;
        protected TextBox txtCostRate;
        protected TextBox txtCSDiscount;
        protected TextBox txtCucFrom01;
        protected TextBox txtCucFrom010;
        protected TextBox txtCucFrom02;
        protected TextBox txtCucFrom03;
        protected TextBox txtCucFrom04;
        protected TextBox txtCucFrom05;
        protected TextBox txtCucFrom06;
        protected TextBox txtCucFrom07;
        protected TextBox txtCucFrom08;
        protected TextBox txtCucFrom09;
        protected TextBox txtCucRate01;
        protected TextBox txtCucRate010;
        protected TextBox txtCucRate02;
        protected TextBox txtCucRate03;
        protected TextBox txtCucRate04;
        protected TextBox txtCucRate05;
        protected TextBox txtCucRate06;
        protected TextBox txtCucRate07;
        protected TextBox txtCucRate08;
        protected TextBox txtCucRate09;
        protected TextBox txtCucTo01;
        protected TextBox txtCucTo010;
        protected TextBox txtCucTo02;
        protected TextBox txtCucTo03;
        protected TextBox txtCucTo04;
        protected TextBox txtCucTo05;
        protected TextBox txtCucTo06;
        protected TextBox txtCucTo07;
        protected TextBox txtCucTo08;
        protected TextBox txtCucTo09;
        protected TextBox txtEADiscount;
        protected TextBox txtFixedRate;
        protected TextBox txtGeneralLedgerID;
        protected TextBox txtIPDiscount;
        protected TextBox txtMaxCharge;
        protected TextBox txtMinCharge;
        protected TextBox txtPLDiscount;
        protected TextBox txtRemark;
        protected TextBox txtStcFrom01;
        protected TextBox txtStcFrom010;
        protected TextBox txtStcFrom02;
        protected TextBox txtStcFrom03;
        protected TextBox txtStcFrom04;
        protected TextBox txtStcFrom05;
        protected TextBox txtStcFrom06;
        protected TextBox txtStcFrom07;
        protected TextBox txtStcFrom08;
        protected TextBox txtStcFrom09;
        protected TextBox txtStcRate01;
        protected TextBox txtStcRate010;
        protected TextBox txtStcRate02;
        protected TextBox txtStcRate03;
        protected TextBox txtStcRate04;
        protected TextBox txtStcRate05;
        protected TextBox txtStcRate06;
        protected TextBox txtStcRate07;
        protected TextBox txtStcRate08;
        protected TextBox txtStcRate09;
        protected TextBox txtStcTo01;
        protected TextBox txtStcTo010;
        protected TextBox txtStcTo02;
        protected TextBox txtStcTo03;
        protected TextBox txtStcTo04;
        protected TextBox txtStcTo05;
        protected TextBox txtStcTo06;
        protected TextBox txtStcTo07;
        protected TextBox txtStcTo08;
        protected TextBox txtStcTo09;
        protected TextBox txtTaxGroupID;
        protected TextBox txtUdf1;
        protected TextBox txtUdf10;
        protected TextBox txtUdf2;
        protected TextBox txtUdf3;
        protected TextBox txtUdf4;
        protected TextBox txtUdf5;
        protected TextBox txtUdf6;
        protected TextBox txtUdf7;
        protected TextBox txtUdf8;
        protected TextBox txtUdf9;
        protected UpdatePanel up1;

        protected void btnCancel_Click(object sender, EventArgs e)
        {
            base.Server.Transfer(string.Format("Rate.aspx?from={0}&detail={1}&ID={2}", base.UrlEncode(this.hdnFrom.Value), "1", base.UrlEncode(this.hdnRateID.Value)));
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            if ((!string.IsNullOrEmpty(this.txtMaxCharge.Text) && !string.IsNullOrEmpty(this.txtMinCharge.Text)) && (decimal.Parse(this.txtMaxCharge.Text) <= decimal.Parse(this.txtMinCharge.Text)))
            {
                this.lblMsg.Text = base.GetGlobalMsgResource("F9150_013");
            }
            else if (string.IsNullOrEmpty(this.ddlDescr.SelectedValue))
            {
                this.lblMsg.Text = base.GetGlobalMsgResource("F9150_002");
            }
            else if ((this.ddlBillingObject.SelectedValue == "BillingEntity") && string.IsNullOrEmpty(this.txtBillingEntity.Text.Trim()))
            {
                this.lblMsg.Text = base.GetGlobalMsgResource("F9150_020");
            }
            else if (this.hdnFlag.Value == "1")
            {
                this.UpdateRateDetail();
            }
            else
            {
                this.InserRateDetail();
            }
        }

        protected void ddlBillingObject_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.ddlBillingObject.SelectedValue.ToUpper() != "BillingEntity".ToUpper())
            {
                this.txtBillingEntity.Enabled = false;
                this.img2.Visible = false;
                this.txtBillingEntity.Text = "";
            }
            else
            {
                this.txtBillingEntity.Enabled = true;
                this.img2.Visible = true;
            }
        }

        protected void ddlChargeMode_TextChanged(object sender, EventArgs e)
        {
            if (this.ddlChargeMode.SelectedValue.ToUpper() == "FIXED")
            {
                this.txtFixedRate.Enabled = true;
                this.txtStcFrom01.Enabled = false;
                this.txtCucFrom01.Enabled = false;
            }
            if (this.ddlChargeMode.SelectedValue.ToUpper() == "CHARGEUNITLEVEL")
            {
                this.txtFixedRate.Enabled = false;
                this.txtStcFrom01.Enabled = false;
                this.txtCucFrom01.Enabled = true;
            }
            if (this.ddlChargeMode.SelectedValue.ToUpper() == "STCTIMELEVEL")
            {
                this.txtFixedRate.Enabled = false;
                this.txtStcFrom01.Enabled = true;
                this.txtCucFrom01.Enabled = false;
            }
        }

        private void InserRateDetail()
        {
            try
            {
                RateDetailInfo rateDetailInfo = new RateDetailInfo {
                    RateID = this.hdnRateID.Value,
                    LineID = Convert.ToInt32(this.hdnLineID.Value),
                    RateType = this.ddlRateType.SelectedValue,
                    CarryMode = this.ddlCarryMode.SelectedValue,
                    ChargeInvocation = this.txtChargeInvocation.Text,
                    ChargeMode = this.ddlChargeMode.SelectedValue
                };
                if (!string.IsNullOrEmpty(this.txtChargePerUnit.Text))
                {
                    rateDetailInfo.ChargePerUnit = decimal.Parse(this.txtChargePerUnit.Text);
                }
                else
                {
                    rateDetailInfo.ChargePerUnit = 0M;
                }
                rateDetailInfo.ChargeUnit = this.ddlChargeUnit.SelectedValue;
                rateDetailInfo.CostingUnit = this.txtCostingUnit.Text;
                rateDetailInfo.CostInvocation = this.txtCostInvocation.Text;
                if (!string.IsNullOrEmpty(this.txtCostPerUnit.Text))
                {
                    rateDetailInfo.CostPerUnit = decimal.Parse(this.txtCostPerUnit.Text);
                }
                else
                {
                    rateDetailInfo.CostPerUnit = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtCostRate.Text))
                {
                    rateDetailInfo.CostRate = decimal.Parse(this.txtCostRate.Text);
                }
                else
                {
                    rateDetailInfo.CostRate = 0M;
                }
                rateDetailInfo.Descr = this.ddlDescr.SelectedValue;
                rateDetailInfo.DistMatchedMode = this.ddlDistMatchedMode.SelectedValue;
                if (!string.IsNullOrEmpty(this.txtFixedRate.Text))
                {
                    rateDetailInfo.FixedRate = decimal.Parse(this.txtFixedRate.Text);
                }
                else
                {
                    rateDetailInfo.FixedRate = 0M;
                }
                rateDetailInfo.GeneralLedgerID = this.txtGeneralLedgerID.Text;
                if (!string.IsNullOrEmpty(this.txtMaxCharge.Text))
                {
                    rateDetailInfo.MaxCharge = decimal.Parse(this.txtMaxCharge.Text);
                }
                else
                {
                    rateDetailInfo.MaxCharge = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtMinCharge.Text))
                {
                    rateDetailInfo.MinCharge = decimal.Parse(this.txtMinCharge.Text);
                }
                else
                {
                    rateDetailInfo.MinCharge = 0M;
                }
                rateDetailInfo.TaxGroupID = this.txtTaxGroupID.Text;
                rateDetailInfo.BillingEntity = this.txtBillingEntity.Text.Trim();
                rateDetailInfo.BillingObject = this.ddlBillingObject.SelectedValue;
                rateDetailInfo.DueFromTo = this.ddlDueFromTo.SelectedValue;
                if (!string.IsNullOrEmpty(this.txtCSDiscount.Text))
                {
                    rateDetailInfo.CsDiscount = decimal.Parse(this.txtCSDiscount.Text);
                }
                else
                {
                    rateDetailInfo.CsDiscount = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtIPDiscount.Text))
                {
                    rateDetailInfo.IpDiscount = decimal.Parse(this.txtIPDiscount.Text);
                }
                else
                {
                    rateDetailInfo.IpDiscount = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtEADiscount.Text))
                {
                    rateDetailInfo.EaDiscount = decimal.Parse(this.txtEADiscount.Text);
                }
                else
                {
                    rateDetailInfo.EaDiscount = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtPLDiscount.Text))
                {
                    rateDetailInfo.PlDiscount = decimal.Parse(this.txtPLDiscount.Text);
                }
                else
                {
                    rateDetailInfo.PlDiscount = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtStcFrom01.Text))
                {
                    rateDetailInfo.StcFrom01 = int.Parse(this.txtStcFrom01.Text);
                }
                else
                {
                    rateDetailInfo.StcFrom01 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtStcFrom02.Text))
                {
                    rateDetailInfo.StcFrom02 = int.Parse(this.txtStcFrom02.Text);
                }
                else
                {
                    rateDetailInfo.StcFrom02 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtStcFrom03.Text))
                {
                    rateDetailInfo.StcFrom03 = int.Parse(this.txtStcFrom03.Text);
                }
                else
                {
                    rateDetailInfo.StcFrom03 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtStcFrom04.Text))
                {
                    rateDetailInfo.StcFrom04 = int.Parse(this.txtStcFrom04.Text);
                }
                else
                {
                    rateDetailInfo.StcFrom04 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtStcFrom05.Text))
                {
                    rateDetailInfo.StcFrom05 = int.Parse(this.txtStcFrom05.Text);
                }
                else
                {
                    rateDetailInfo.StcFrom05 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtStcFrom06.Text))
                {
                    rateDetailInfo.StcFrom06 = int.Parse(this.txtStcFrom06.Text);
                }
                else
                {
                    rateDetailInfo.StcFrom06 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtStcFrom07.Text))
                {
                    rateDetailInfo.StcFrom07 = int.Parse(this.txtStcFrom07.Text);
                }
                else
                {
                    rateDetailInfo.StcFrom07 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtStcFrom08.Text))
                {
                    rateDetailInfo.StcFrom08 = int.Parse(this.txtStcFrom08.Text);
                }
                else
                {
                    rateDetailInfo.StcFrom08 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtStcFrom09.Text))
                {
                    rateDetailInfo.StcFrom09 = int.Parse(this.txtStcFrom09.Text);
                }
                else
                {
                    rateDetailInfo.StcFrom09 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtStcFrom010.Text))
                {
                    rateDetailInfo.StcFrom10 = int.Parse(this.txtStcFrom010.Text);
                }
                else
                {
                    rateDetailInfo.StcFrom10 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtStcRate01.Text))
                {
                    rateDetailInfo.StcRate01 = decimal.Parse(this.txtStcRate01.Text);
                }
                else
                {
                    rateDetailInfo.StcRate01 = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtStcRate02.Text))
                {
                    rateDetailInfo.StcRate02 = decimal.Parse(this.txtStcRate02.Text);
                }
                else
                {
                    rateDetailInfo.StcRate02 = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtStcRate03.Text))
                {
                    rateDetailInfo.StcRate03 = decimal.Parse(this.txtStcRate03.Text);
                }
                else
                {
                    rateDetailInfo.StcRate03 = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtStcRate04.Text))
                {
                    rateDetailInfo.StcRate04 = decimal.Parse(this.txtStcRate04.Text);
                }
                else
                {
                    rateDetailInfo.StcRate04 = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtStcRate05.Text))
                {
                    rateDetailInfo.StcRate05 = decimal.Parse(this.txtStcRate05.Text);
                }
                else
                {
                    rateDetailInfo.StcRate05 = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtStcRate06.Text))
                {
                    rateDetailInfo.StcRate06 = decimal.Parse(this.txtStcRate06.Text);
                }
                else
                {
                    rateDetailInfo.StcRate06 = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtStcRate07.Text))
                {
                    rateDetailInfo.StcRate07 = decimal.Parse(this.txtStcRate07.Text);
                }
                else
                {
                    rateDetailInfo.StcRate07 = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtStcRate08.Text))
                {
                    rateDetailInfo.StcRate08 = decimal.Parse(this.txtStcRate08.Text);
                }
                else
                {
                    rateDetailInfo.StcRate08 = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtStcRate09.Text))
                {
                    rateDetailInfo.StcRate09 = decimal.Parse(this.txtStcRate09.Text);
                }
                else
                {
                    rateDetailInfo.StcRate09 = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtStcRate010.Text))
                {
                    rateDetailInfo.StcRate10 = decimal.Parse(this.txtStcRate010.Text);
                }
                else
                {
                    rateDetailInfo.StcRate10 = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtStcTo01.Text))
                {
                    rateDetailInfo.StcTo01 = int.Parse(this.txtStcTo01.Text);
                }
                else
                {
                    rateDetailInfo.StcTo01 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtStcTo02.Text))
                {
                    rateDetailInfo.StcTo02 = int.Parse(this.txtStcTo02.Text);
                }
                else
                {
                    rateDetailInfo.StcTo02 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtStcTo03.Text))
                {
                    rateDetailInfo.StcTo03 = int.Parse(this.txtStcTo03.Text);
                }
                else
                {
                    rateDetailInfo.StcTo03 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtStcTo04.Text))
                {
                    rateDetailInfo.StcTo04 = int.Parse(this.txtStcTo04.Text);
                }
                else
                {
                    rateDetailInfo.StcTo04 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtStcTo05.Text))
                {
                    rateDetailInfo.StcTo05 = int.Parse(this.txtStcTo05.Text);
                }
                else
                {
                    rateDetailInfo.StcTo05 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtStcTo06.Text))
                {
                    rateDetailInfo.StcTo06 = int.Parse(this.txtStcTo06.Text);
                }
                else
                {
                    rateDetailInfo.StcTo06 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtStcTo07.Text))
                {
                    rateDetailInfo.StcTo07 = int.Parse(this.txtStcTo07.Text);
                }
                else
                {
                    rateDetailInfo.StcTo07 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtStcTo08.Text))
                {
                    rateDetailInfo.StcTo08 = int.Parse(this.txtStcTo08.Text);
                }
                else
                {
                    rateDetailInfo.StcTo08 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtStcTo09.Text))
                {
                    rateDetailInfo.StcTo09 = int.Parse(this.txtStcTo09.Text);
                }
                else
                {
                    rateDetailInfo.StcTo09 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtStcTo010.Text))
                {
                    rateDetailInfo.StcTo10 = int.Parse(this.txtStcTo010.Text);
                }
                else
                {
                    rateDetailInfo.StcTo10 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtCucFrom01.Text))
                {
                    rateDetailInfo.CucFrom01 = int.Parse(this.txtCucFrom01.Text);
                }
                else
                {
                    rateDetailInfo.CucFrom01 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtCucFrom02.Text))
                {
                    rateDetailInfo.CucFrom02 = int.Parse(this.txtCucFrom02.Text);
                }
                else
                {
                    rateDetailInfo.CucFrom02 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtCucFrom03.Text))
                {
                    rateDetailInfo.CucFrom03 = int.Parse(this.txtCucFrom03.Text);
                }
                else
                {
                    rateDetailInfo.CucFrom03 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtCucFrom04.Text))
                {
                    rateDetailInfo.CucFrom04 = int.Parse(this.txtCucFrom04.Text);
                }
                else
                {
                    rateDetailInfo.CucFrom04 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtCucFrom05.Text))
                {
                    rateDetailInfo.CucFrom05 = int.Parse(this.txtCucFrom05.Text);
                }
                else
                {
                    rateDetailInfo.CucFrom05 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtCucFrom06.Text))
                {
                    rateDetailInfo.CucFrom06 = int.Parse(this.txtCucFrom06.Text);
                }
                else
                {
                    rateDetailInfo.CucFrom06 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtCucFrom07.Text))
                {
                    rateDetailInfo.CucFrom07 = int.Parse(this.txtCucFrom07.Text);
                }
                else
                {
                    rateDetailInfo.CucFrom07 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtCucFrom08.Text))
                {
                    rateDetailInfo.CucFrom08 = int.Parse(this.txtCucFrom08.Text);
                }
                else
                {
                    rateDetailInfo.CucFrom08 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtCucFrom09.Text))
                {
                    rateDetailInfo.CucFrom09 = int.Parse(this.txtCucFrom09.Text);
                }
                else
                {
                    rateDetailInfo.CucFrom09 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtCucFrom010.Text))
                {
                    rateDetailInfo.CucFrom10 = int.Parse(this.txtCucFrom010.Text);
                }
                else
                {
                    rateDetailInfo.CucFrom10 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtCucRate01.Text))
                {
                    rateDetailInfo.CucRate01 = decimal.Parse(this.txtCucRate01.Text);
                }
                else
                {
                    rateDetailInfo.CucRate01 = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtCucRate02.Text))
                {
                    rateDetailInfo.CucRate02 = decimal.Parse(this.txtCucRate02.Text);
                }
                else
                {
                    rateDetailInfo.CucRate02 = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtCucRate03.Text))
                {
                    rateDetailInfo.CucRate03 = decimal.Parse(this.txtCucRate03.Text);
                }
                else
                {
                    rateDetailInfo.CucRate03 = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtCucRate04.Text))
                {
                    rateDetailInfo.CucRate04 = decimal.Parse(this.txtCucRate04.Text);
                }
                else
                {
                    rateDetailInfo.CucRate04 = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtCucRate05.Text))
                {
                    rateDetailInfo.CucRate05 = decimal.Parse(this.txtCucRate05.Text);
                }
                else
                {
                    rateDetailInfo.CucRate05 = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtCucRate06.Text))
                {
                    rateDetailInfo.CucRate06 = decimal.Parse(this.txtCucRate06.Text);
                }
                else
                {
                    rateDetailInfo.CucRate06 = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtCucRate07.Text))
                {
                    rateDetailInfo.CucRate07 = decimal.Parse(this.txtCucRate07.Text);
                }
                else
                {
                    rateDetailInfo.CucRate07 = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtCucRate08.Text))
                {
                    rateDetailInfo.CucRate08 = decimal.Parse(this.txtCucRate08.Text);
                }
                else
                {
                    rateDetailInfo.CucRate08 = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtCucRate09.Text))
                {
                    rateDetailInfo.CucRate09 = decimal.Parse(this.txtCucRate09.Text);
                }
                else
                {
                    rateDetailInfo.CucRate09 = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtCucRate010.Text))
                {
                    rateDetailInfo.CucRate10 = decimal.Parse(this.txtCucRate010.Text);
                }
                else
                {
                    rateDetailInfo.CucRate10 = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtCucTo01.Text))
                {
                    rateDetailInfo.CucTo01 = int.Parse(this.txtCucTo01.Text);
                }
                else
                {
                    rateDetailInfo.CucTo01 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtCucTo02.Text))
                {
                    rateDetailInfo.CucTo02 = int.Parse(this.txtCucTo02.Text);
                }
                else
                {
                    rateDetailInfo.CucTo02 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtCucTo03.Text))
                {
                    rateDetailInfo.CucTo03 = int.Parse(this.txtCucTo03.Text);
                }
                else
                {
                    rateDetailInfo.CucTo03 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtCucTo04.Text))
                {
                    rateDetailInfo.CucTo04 = int.Parse(this.txtCucTo04.Text);
                }
                else
                {
                    rateDetailInfo.CucTo04 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtCucTo05.Text))
                {
                    rateDetailInfo.CucTo05 = int.Parse(this.txtCucTo05.Text);
                }
                else
                {
                    rateDetailInfo.CucTo05 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtCucTo06.Text))
                {
                    rateDetailInfo.CucTo06 = int.Parse(this.txtCucTo06.Text);
                }
                else
                {
                    rateDetailInfo.CucTo06 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtCucTo07.Text))
                {
                    rateDetailInfo.CucTo07 = int.Parse(this.txtCucTo07.Text);
                }
                else
                {
                    rateDetailInfo.CucTo07 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtCucTo08.Text))
                {
                    rateDetailInfo.CucTo08 = int.Parse(this.txtCucTo08.Text);
                }
                else
                {
                    rateDetailInfo.CucTo08 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtCucTo09.Text))
                {
                    rateDetailInfo.CucTo09 = int.Parse(this.txtCucTo09.Text);
                }
                else
                {
                    rateDetailInfo.CucTo09 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtCucTo010.Text))
                {
                    rateDetailInfo.CucTo10 = int.Parse(this.txtCucTo010.Text);
                }
                else
                {
                    rateDetailInfo.CucTo10 = 0;
                }
                rateDetailInfo.Udf1 = this.txtUdf1.Text;
                rateDetailInfo.Udf2 = this.txtUdf2.Text;
                rateDetailInfo.Udf3 = this.txtUdf3.Text;
                rateDetailInfo.Udf4 = this.txtUdf4.Text;
                rateDetailInfo.Udf5 = this.txtUdf5.Text;
                rateDetailInfo.Udf6 = this.txtUdf6.Text;
                rateDetailInfo.Udf7 = this.txtUdf7.Text;
                rateDetailInfo.Udf8 = this.txtUdf8.Text;
                rateDetailInfo.Udf9 = this.txtUdf9.Text;
                rateDetailInfo.Udf10 = this.txtUdf10.Text;
                rateDetailInfo.IsActive = this.chkIsActive.Checked ? "Y" : "N";
                rateDetailInfo.CreatedBy = base.UserInfo.UserID;
                this.lblMsg.Text = BaseInfoDetailServiceClientProxy.GetInstance().InsertDetail(rateDetailInfo, "RATE_DETAIL") + base.GetGlobalMsgResource("F9150_005");
                this.hdnFlag.Value = "1";
                base.Server.Transfer(string.Format("Rate.aspx?from={0}&detail={1}&ID={2}", base.UrlEncode(this.hdnFrom.Value), "1", base.UrlEncode(this.hdnRateID.Value)));
            }
            catch (Exception ex)
            {
                this.lblMsg.Text = base.GetGlobalMsgResource("F9150_014") + ex.Message;
            }
        }

        private void LoadData()
        {
            if (!string.IsNullOrEmpty(base.Request.QueryString["from"]))
            {
                string from = base.Request.QueryString["from"];
                this.hdnFrom.Value = from;
            }
            if (!string.IsNullOrEmpty(base.Request.QueryString["ID"]))
            {
                this.hdnRateID.Value = base.Request.QueryString["ID"];
            }
            if (!string.IsNullOrEmpty(base.Request.QueryString["LineID"]))
            {
                this.hdnLineID.Value = base.Request.QueryString["LineID"];
            }
            base.BindData2DDLBySysCode(this.ddlChargeUnit, "ChargeUnit");
            base.BindData2DDLBySysCode(this.ddlRateType, "ChargeType");
            base.BindData2DDLBySysCode(this.ddlChargeMode, "BillingMode");
            base.BindData2DDLBySysCode(this.ddlDistMatchedMode, "DistMatchedMode");
            base.BindData2DDLBySysCode(this.ddlCarryMode, "CarryMode");
            base.BindData2DDLBySysCode(this.ddlDescr, "CostType");
            base.BindData2DDLBySysCode(this.ddlBillingObject, "BillingObject");
            base.BindData2DDLBySysCode(this.ddlDueFromTo, "DueFromTo");
            if (!string.IsNullOrEmpty(base.Request.QueryString["Type"]))
            {
                this.SetTextBoxByRateDetail();
                this.hdnFlag.Value = "1";
            }
            this.ddlBillingObject_SelectedIndexChanged(null, null);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                base.InitPage(this.Page);
                this.LoadData();
            }
        }

        private void SetTextBoxByRateDetail()
        {
            RateDetailInfo rateDetailInfo = BaseInfoDetailServiceClientProxy.GetInstance().GetDetailInfoByID(this.hdnRateID.Value, this.hdnLineID.Value, "", "RATE_DETAIL") as RateDetailInfo;
            if (rateDetailInfo != null)
            {
                base.DataEntityViewState = rateDetailInfo;
                this.ddlRateType.SelectedValue = rateDetailInfo.RateType;
                this.ddlCarryMode.SelectedValue = rateDetailInfo.CarryMode;
                this.txtChargeInvocation.Text = rateDetailInfo.ChargeInvocation;
                this.ddlChargeMode.SelectedValue = rateDetailInfo.ChargeMode;
                this.ddlDescr.SelectedValue = rateDetailInfo.Descr;
                this.ddlBillingObject.SelectedValue = rateDetailInfo.BillingObject;
                this.ddlDueFromTo.SelectedValue = rateDetailInfo.DueFromTo;
                if (rateDetailInfo.ChargePerUnit > 0M)
                {
                    this.txtChargePerUnit.Text = base.GetPreferenceDigit(rateDetailInfo.ChargePerUnit);
                }
                this.ddlChargeUnit.SelectedValue = rateDetailInfo.ChargeUnit;
                this.txtCostingUnit.Text = rateDetailInfo.CostingUnit;
                this.txtCostInvocation.Text = rateDetailInfo.CostInvocation;
                this.txtBillingEntity.Text = rateDetailInfo.BillingEntity;
                if (rateDetailInfo.CostPerUnit > 0M)
                {
                    this.txtCostPerUnit.Text = base.GetPreferenceDigit(rateDetailInfo.CostPerUnit);
                }
                if (rateDetailInfo.CostRate > 0M)
                {
                    this.txtCostRate.Text = base.GetPreferenceDigit(rateDetailInfo.CostRate);
                }
                this.ddlDistMatchedMode.SelectedValue = rateDetailInfo.DistMatchedMode;
                if (rateDetailInfo.FixedRate > 0M)
                {
                    this.txtFixedRate.Text = base.GetPreferenceDigit(rateDetailInfo.FixedRate);
                }
                this.txtGeneralLedgerID.Text = rateDetailInfo.GeneralLedgerID;
                if (rateDetailInfo.MaxCharge > 0M)
                {
                    this.txtMaxCharge.Text = base.GetPreferenceDigit(rateDetailInfo.MaxCharge);
                }
                if (rateDetailInfo.MinCharge > 0M)
                {
                    this.txtMinCharge.Text = base.GetPreferenceDigit(rateDetailInfo.MinCharge);
                }
                this.txtTaxGroupID.Text = rateDetailInfo.TaxGroupID;
                if (rateDetailInfo.CsDiscount > 0M)
                {
                    this.txtCSDiscount.Text = base.GetPreferenceDigit(rateDetailInfo.CsDiscount);
                }
                if (rateDetailInfo.IpDiscount > 0M)
                {
                    this.txtIPDiscount.Text = base.GetPreferenceDigit(rateDetailInfo.IpDiscount);
                }
                if (rateDetailInfo.EaDiscount > 0M)
                {
                    this.txtEADiscount.Text = base.GetPreferenceDigit(rateDetailInfo.EaDiscount);
                }
                if (rateDetailInfo.PlDiscount > 0M)
                {
                    this.txtPLDiscount.Text = base.GetPreferenceDigit(rateDetailInfo.PlDiscount);
                }
                if (rateDetailInfo.StcFrom01 > 0)
                {
                    this.txtStcFrom01.Text = rateDetailInfo.StcFrom01.ToString();
                }
                if (rateDetailInfo.StcFrom02 > 0)
                {
                    this.txtStcFrom02.Text = rateDetailInfo.StcFrom02.ToString();
                }
                if (rateDetailInfo.StcFrom03 > 0)
                {
                    this.txtStcFrom03.Text = rateDetailInfo.StcFrom03.ToString();
                }
                if (rateDetailInfo.StcFrom04 > 0)
                {
                    this.txtStcFrom04.Text = rateDetailInfo.StcFrom04.ToString();
                }
                if (rateDetailInfo.StcFrom05 > 0)
                {
                    this.txtStcFrom05.Text = rateDetailInfo.StcFrom05.ToString();
                }
                if (rateDetailInfo.StcFrom06 > 0)
                {
                    this.txtStcFrom06.Text = rateDetailInfo.StcFrom06.ToString();
                }
                if (rateDetailInfo.StcFrom07 > 0)
                {
                    this.txtStcFrom07.Text = rateDetailInfo.StcFrom07.ToString();
                }
                if (rateDetailInfo.StcFrom08 > 0)
                {
                    this.txtStcFrom08.Text = rateDetailInfo.StcFrom08.ToString();
                }
                if (rateDetailInfo.StcFrom09 > 0)
                {
                    this.txtStcFrom09.Text = rateDetailInfo.StcFrom09.ToString();
                }
                if (rateDetailInfo.StcFrom10 > 0)
                {
                    this.txtStcFrom010.Text = rateDetailInfo.StcFrom10.ToString();
                }
                if (rateDetailInfo.StcRate01 > 0M)
                {
                    this.txtStcRate01.Text = base.GetPreferenceDigit(rateDetailInfo.StcRate01);
                }
                if (rateDetailInfo.StcRate02 > 0M)
                {
                    this.txtStcRate02.Text = base.GetPreferenceDigit(rateDetailInfo.StcRate02);
                }
                if (rateDetailInfo.StcRate03 > 0M)
                {
                    this.txtStcRate03.Text = base.GetPreferenceDigit(rateDetailInfo.StcRate03);
                }
                if (rateDetailInfo.StcRate04 > 0M)
                {
                    this.txtStcRate04.Text = base.GetPreferenceDigit(rateDetailInfo.StcRate04);
                }
                if (rateDetailInfo.StcRate05 > 0M)
                {
                    this.txtStcRate05.Text = base.GetPreferenceDigit(rateDetailInfo.StcRate05);
                }
                if (rateDetailInfo.StcRate06 > 0M)
                {
                    this.txtStcRate06.Text = base.GetPreferenceDigit(rateDetailInfo.StcRate06);
                }
                if (rateDetailInfo.StcRate07 > 0M)
                {
                    this.txtStcRate07.Text = base.GetPreferenceDigit(rateDetailInfo.StcRate07);
                }
                if (rateDetailInfo.StcRate08 > 0M)
                {
                    this.txtStcRate08.Text = base.GetPreferenceDigit(rateDetailInfo.StcRate08);
                }
                if (rateDetailInfo.StcRate09 > 0M)
                {
                    this.txtStcRate09.Text = base.GetPreferenceDigit(rateDetailInfo.StcRate09);
                }
                if (rateDetailInfo.StcRate10 > 0M)
                {
                    this.txtStcRate010.Text = base.GetPreferenceDigit(rateDetailInfo.StcRate10);
                }
                if (rateDetailInfo.StcTo01 > 0)
                {
                    this.txtStcTo01.Text = rateDetailInfo.StcTo01.ToString();
                }
                if (rateDetailInfo.StcTo02 > 0)
                {
                    this.txtStcTo02.Text = rateDetailInfo.StcTo02.ToString();
                }
                if (rateDetailInfo.StcTo03 > 0)
                {
                    this.txtStcTo03.Text = rateDetailInfo.StcTo03.ToString();
                }
                if (rateDetailInfo.StcTo04 > 0)
                {
                    this.txtStcTo04.Text = rateDetailInfo.StcTo04.ToString();
                }
                if (rateDetailInfo.StcTo05 > 0)
                {
                    this.txtStcTo05.Text = rateDetailInfo.StcTo05.ToString();
                }
                if (rateDetailInfo.StcTo06 > 0)
                {
                    this.txtStcTo06.Text = rateDetailInfo.StcTo06.ToString();
                }
                if (rateDetailInfo.StcTo07 > 0)
                {
                    this.txtStcTo07.Text = rateDetailInfo.StcTo07.ToString();
                }
                if (rateDetailInfo.StcTo08 > 0)
                {
                    this.txtStcTo08.Text = rateDetailInfo.StcTo08.ToString();
                }
                if (rateDetailInfo.StcTo09 > 0)
                {
                    this.txtStcTo09.Text = rateDetailInfo.StcTo09.ToString();
                }
                if (rateDetailInfo.StcTo10 > 0)
                {
                    this.txtStcTo010.Text = rateDetailInfo.StcTo10.ToString();
                }
                if (rateDetailInfo.CucFrom01 > 0)
                {
                    this.txtCucFrom01.Text = rateDetailInfo.CucFrom01.ToString();
                }
                if (rateDetailInfo.CucFrom02 > 0)
                {
                    this.txtCucFrom02.Text = rateDetailInfo.CucFrom02.ToString();
                }
                if (rateDetailInfo.CucFrom03 > 0)
                {
                    this.txtCucFrom03.Text = rateDetailInfo.CucFrom03.ToString();
                }
                if (rateDetailInfo.CucFrom04 > 0)
                {
                    this.txtCucFrom04.Text = rateDetailInfo.CucFrom04.ToString();
                }
                if (rateDetailInfo.CucFrom05 > 0)
                {
                    this.txtCucFrom05.Text = rateDetailInfo.CucFrom05.ToString();
                }
                if (rateDetailInfo.CucFrom06 > 0)
                {
                    this.txtCucFrom06.Text = rateDetailInfo.CucFrom06.ToString();
                }
                if (rateDetailInfo.CucFrom07 > 0)
                {
                    this.txtCucFrom07.Text = rateDetailInfo.CucFrom07.ToString();
                }
                if (rateDetailInfo.CucFrom08 > 0)
                {
                    this.txtCucFrom08.Text = rateDetailInfo.CucFrom08.ToString();
                }
                if (rateDetailInfo.CucFrom09 > 0)
                {
                    this.txtCucFrom09.Text = rateDetailInfo.CucFrom09.ToString();
                }
                if (rateDetailInfo.CucFrom10 > 0)
                {
                    this.txtCucFrom010.Text = rateDetailInfo.CucFrom10.ToString();
                }
                if (rateDetailInfo.CucRate01 > 0M)
                {
                    this.txtCucRate01.Text = base.GetPreferenceDigit(rateDetailInfo.CucRate01);
                }
                if (rateDetailInfo.CucRate02 > 0M)
                {
                    this.txtCucRate02.Text = base.GetPreferenceDigit(rateDetailInfo.CucRate02);
                }
                if (rateDetailInfo.CucRate03 > 0M)
                {
                    this.txtCucRate03.Text = base.GetPreferenceDigit(rateDetailInfo.CucRate03);
                }
                if (rateDetailInfo.CucRate04 > 0M)
                {
                    this.txtCucRate04.Text = base.GetPreferenceDigit(rateDetailInfo.CucRate04);
                }
                if (rateDetailInfo.CucRate05 > 0M)
                {
                    this.txtCucRate05.Text = base.GetPreferenceDigit(rateDetailInfo.CucRate05);
                }
                if (rateDetailInfo.CucRate06 > 0M)
                {
                    this.txtCucRate06.Text = base.GetPreferenceDigit(rateDetailInfo.CucRate06);
                }
                if (rateDetailInfo.CucRate07 > 0M)
                {
                    this.txtCucRate07.Text = base.GetPreferenceDigit(rateDetailInfo.CucRate07);
                }
                if (rateDetailInfo.CucRate08 > 0M)
                {
                    this.txtCucRate08.Text = base.GetPreferenceDigit(rateDetailInfo.CucRate08);
                }
                if (rateDetailInfo.CucRate09 > 0M)
                {
                    this.txtCucRate09.Text = base.GetPreferenceDigit(rateDetailInfo.CucRate09);
                }
                if (rateDetailInfo.CucRate10 > 0M)
                {
                    this.txtCucRate010.Text = base.GetPreferenceDigit(rateDetailInfo.CucRate10);
                }
                if (rateDetailInfo.CucTo01 > 0)
                {
                    this.txtCucTo01.Text = rateDetailInfo.CucTo01.ToString();
                }
                if (rateDetailInfo.CucTo02 > 0)
                {
                    this.txtCucTo02.Text = rateDetailInfo.CucTo02.ToString();
                }
                if (rateDetailInfo.CucTo03 > 0)
                {
                    this.txtCucTo03.Text = rateDetailInfo.CucTo03.ToString();
                }
                if (rateDetailInfo.CucTo04 > 0)
                {
                    this.txtCucTo04.Text = rateDetailInfo.CucTo04.ToString();
                }
                if (rateDetailInfo.CucTo05 > 0)
                {
                    this.txtCucTo05.Text = rateDetailInfo.CucTo05.ToString();
                }
                if (rateDetailInfo.CucTo06 > 0)
                {
                    this.txtCucTo06.Text = rateDetailInfo.CucTo06.ToString();
                }
                if (rateDetailInfo.CucTo07 > 0)
                {
                    this.txtCucTo07.Text = rateDetailInfo.CucTo07.ToString();
                }
                if (rateDetailInfo.CucTo08 > 0)
                {
                    this.txtCucTo08.Text = rateDetailInfo.CucTo08.ToString();
                }
                if (rateDetailInfo.CucTo09 > 0)
                {
                    this.txtCucTo09.Text = rateDetailInfo.CucTo09.ToString();
                }
                if (rateDetailInfo.CucTo10 > 0)
                {
                    this.txtCucTo010.Text = rateDetailInfo.CucTo10.ToString();
                }
                this.txtUdf1.Text = rateDetailInfo.Udf1;
                this.txtUdf2.Text = rateDetailInfo.Udf2;
                this.txtUdf3.Text = rateDetailInfo.Udf3;
                this.txtUdf4.Text = rateDetailInfo.Udf4;
                this.txtUdf5.Text = rateDetailInfo.Udf5;
                this.txtUdf6.Text = rateDetailInfo.Udf6;
                this.txtUdf7.Text = rateDetailInfo.Udf7;
                this.txtUdf8.Text = rateDetailInfo.Udf8;
                this.txtUdf9.Text = rateDetailInfo.Udf9;
                this.txtUdf10.Text = rateDetailInfo.Udf10;
                this.chkIsActive.Checked = rateDetailInfo.IsActive == "Y";
                this.ddlChargeMode_TextChanged(null, null);
            }
        }

        private void UpdateRateDetail()
        {
            try
            {
                RateDetailInfo rateDetailInfo = base.DataEntityViewState as RateDetailInfo;
                rateDetailInfo.RateType = this.ddlRateType.SelectedValue;
                rateDetailInfo.CarryMode = this.ddlCarryMode.SelectedValue;
                rateDetailInfo.ChargeInvocation = this.txtChargeInvocation.Text;
                rateDetailInfo.ChargeMode = this.ddlChargeMode.SelectedValue;
                if (!string.IsNullOrEmpty(this.txtChargePerUnit.Text))
                {
                    rateDetailInfo.ChargePerUnit = decimal.Parse(this.txtChargePerUnit.Text);
                }
                else
                {
                    rateDetailInfo.ChargePerUnit = 0M;
                }
                rateDetailInfo.ChargeUnit = this.ddlChargeUnit.SelectedValue;
                rateDetailInfo.CostingUnit = this.txtCostingUnit.Text;
                rateDetailInfo.CostInvocation = this.txtCostInvocation.Text;
                if (!string.IsNullOrEmpty(this.txtCostPerUnit.Text))
                {
                    rateDetailInfo.CostPerUnit = decimal.Parse(this.txtCostPerUnit.Text);
                }
                else
                {
                    rateDetailInfo.CostPerUnit = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtCostRate.Text))
                {
                    rateDetailInfo.CostRate = decimal.Parse(this.txtCostRate.Text);
                }
                else
                {
                    rateDetailInfo.CostRate = 0M;
                }
                rateDetailInfo.Descr = this.ddlDescr.SelectedValue;
                rateDetailInfo.DistMatchedMode = this.ddlDistMatchedMode.SelectedValue;
                if (!string.IsNullOrEmpty(this.txtFixedRate.Text))
                {
                    rateDetailInfo.FixedRate = decimal.Parse(this.txtFixedRate.Text);
                }
                else
                {
                    rateDetailInfo.FixedRate = 0M;
                }
                rateDetailInfo.GeneralLedgerID = this.txtGeneralLedgerID.Text;
                if (!string.IsNullOrEmpty(this.txtMaxCharge.Text))
                {
                    rateDetailInfo.MaxCharge = decimal.Parse(this.txtMaxCharge.Text);
                }
                else
                {
                    rateDetailInfo.MaxCharge = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtMinCharge.Text))
                {
                    rateDetailInfo.MinCharge = decimal.Parse(this.txtMinCharge.Text);
                }
                else
                {
                    rateDetailInfo.MinCharge = 0M;
                }
                rateDetailInfo.TaxGroupID = this.txtTaxGroupID.Text;
                rateDetailInfo.BillingEntity = this.txtBillingEntity.Text.Trim();
                rateDetailInfo.BillingObject = this.ddlBillingObject.SelectedValue;
                rateDetailInfo.DueFromTo = this.ddlDueFromTo.SelectedValue;
                if (!string.IsNullOrEmpty(this.txtCSDiscount.Text))
                {
                    rateDetailInfo.CsDiscount = decimal.Parse(this.txtCSDiscount.Text);
                }
                else
                {
                    rateDetailInfo.CsDiscount = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtIPDiscount.Text))
                {
                    rateDetailInfo.IpDiscount = decimal.Parse(this.txtIPDiscount.Text);
                }
                else
                {
                    rateDetailInfo.IpDiscount = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtEADiscount.Text))
                {
                    rateDetailInfo.EaDiscount = decimal.Parse(this.txtEADiscount.Text);
                }
                else
                {
                    rateDetailInfo.EaDiscount = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtPLDiscount.Text))
                {
                    rateDetailInfo.PlDiscount = decimal.Parse(this.txtPLDiscount.Text);
                }
                else
                {
                    rateDetailInfo.PlDiscount = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtStcFrom01.Text))
                {
                    rateDetailInfo.StcFrom01 = int.Parse(this.txtStcFrom01.Text);
                }
                else
                {
                    rateDetailInfo.StcFrom01 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtStcFrom02.Text))
                {
                    rateDetailInfo.StcFrom02 = int.Parse(this.txtStcFrom02.Text);
                }
                else
                {
                    rateDetailInfo.StcFrom02 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtStcFrom03.Text))
                {
                    rateDetailInfo.StcFrom03 = int.Parse(this.txtStcFrom03.Text);
                }
                else
                {
                    rateDetailInfo.StcFrom03 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtStcFrom04.Text))
                {
                    rateDetailInfo.StcFrom04 = int.Parse(this.txtStcFrom04.Text);
                }
                else
                {
                    rateDetailInfo.StcFrom04 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtStcFrom05.Text))
                {
                    rateDetailInfo.StcFrom05 = int.Parse(this.txtStcFrom05.Text);
                }
                else
                {
                    rateDetailInfo.StcFrom05 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtStcFrom06.Text))
                {
                    rateDetailInfo.StcFrom06 = int.Parse(this.txtStcFrom06.Text);
                }
                else
                {
                    rateDetailInfo.StcFrom06 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtStcFrom07.Text))
                {
                    rateDetailInfo.StcFrom07 = int.Parse(this.txtStcFrom07.Text);
                }
                else
                {
                    rateDetailInfo.StcFrom07 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtStcFrom08.Text))
                {
                    rateDetailInfo.StcFrom08 = int.Parse(this.txtStcFrom08.Text);
                }
                else
                {
                    rateDetailInfo.StcFrom08 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtStcFrom09.Text))
                {
                    rateDetailInfo.StcFrom09 = int.Parse(this.txtStcFrom09.Text);
                }
                else
                {
                    rateDetailInfo.StcFrom09 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtStcFrom010.Text))
                {
                    rateDetailInfo.StcFrom10 = int.Parse(this.txtStcFrom010.Text);
                }
                else
                {
                    rateDetailInfo.StcFrom10 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtStcRate01.Text))
                {
                    rateDetailInfo.StcRate01 = decimal.Parse(this.txtStcRate01.Text);
                }
                else
                {
                    rateDetailInfo.StcRate01 = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtStcRate02.Text))
                {
                    rateDetailInfo.StcRate02 = decimal.Parse(this.txtStcRate02.Text);
                }
                else
                {
                    rateDetailInfo.StcRate02 = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtStcRate03.Text))
                {
                    rateDetailInfo.StcRate03 = decimal.Parse(this.txtStcRate03.Text);
                }
                else
                {
                    rateDetailInfo.StcRate03 = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtStcRate04.Text))
                {
                    rateDetailInfo.StcRate04 = decimal.Parse(this.txtStcRate04.Text);
                }
                else
                {
                    rateDetailInfo.StcRate04 = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtStcRate05.Text))
                {
                    rateDetailInfo.StcRate05 = decimal.Parse(this.txtStcRate05.Text);
                }
                else
                {
                    rateDetailInfo.StcRate05 = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtStcRate06.Text))
                {
                    rateDetailInfo.StcRate06 = decimal.Parse(this.txtStcRate06.Text);
                }
                else
                {
                    rateDetailInfo.StcRate06 = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtStcRate07.Text))
                {
                    rateDetailInfo.StcRate07 = decimal.Parse(this.txtStcRate07.Text);
                }
                else
                {
                    rateDetailInfo.StcRate07 = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtStcRate08.Text))
                {
                    rateDetailInfo.StcRate08 = decimal.Parse(this.txtStcRate08.Text);
                }
                else
                {
                    rateDetailInfo.StcRate08 = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtStcRate09.Text))
                {
                    rateDetailInfo.StcRate09 = decimal.Parse(this.txtStcRate09.Text);
                }
                else
                {
                    rateDetailInfo.StcRate09 = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtStcRate010.Text))
                {
                    rateDetailInfo.StcRate10 = decimal.Parse(this.txtStcRate010.Text);
                }
                else
                {
                    rateDetailInfo.StcRate10 = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtStcTo01.Text))
                {
                    rateDetailInfo.StcTo01 = int.Parse(this.txtStcTo01.Text);
                }
                else
                {
                    rateDetailInfo.StcTo01 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtStcTo02.Text))
                {
                    rateDetailInfo.StcTo02 = int.Parse(this.txtStcTo02.Text);
                }
                else
                {
                    rateDetailInfo.StcTo02 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtStcTo03.Text))
                {
                    rateDetailInfo.StcTo03 = int.Parse(this.txtStcTo03.Text);
                }
                else
                {
                    rateDetailInfo.StcTo03 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtStcTo04.Text))
                {
                    rateDetailInfo.StcTo04 = int.Parse(this.txtStcTo04.Text);
                }
                else
                {
                    rateDetailInfo.StcTo04 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtStcTo05.Text))
                {
                    rateDetailInfo.StcTo05 = int.Parse(this.txtStcTo05.Text);
                }
                else
                {
                    rateDetailInfo.StcTo05 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtStcTo06.Text))
                {
                    rateDetailInfo.StcTo06 = int.Parse(this.txtStcTo06.Text);
                }
                else
                {
                    rateDetailInfo.StcTo06 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtStcTo07.Text))
                {
                    rateDetailInfo.StcTo07 = int.Parse(this.txtStcTo07.Text);
                }
                else
                {
                    rateDetailInfo.StcTo07 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtStcTo08.Text))
                {
                    rateDetailInfo.StcTo08 = int.Parse(this.txtStcTo08.Text);
                }
                else
                {
                    rateDetailInfo.StcTo08 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtStcTo09.Text))
                {
                    rateDetailInfo.StcTo09 = int.Parse(this.txtStcTo09.Text);
                }
                else
                {
                    rateDetailInfo.StcTo09 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtStcTo010.Text))
                {
                    rateDetailInfo.StcTo10 = int.Parse(this.txtStcTo010.Text);
                }
                else
                {
                    rateDetailInfo.StcTo10 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtCucFrom01.Text))
                {
                    rateDetailInfo.CucFrom01 = int.Parse(this.txtCucFrom01.Text);
                }
                else
                {
                    rateDetailInfo.CucFrom01 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtCucFrom02.Text))
                {
                    rateDetailInfo.CucFrom02 = int.Parse(this.txtCucFrom02.Text);
                }
                else
                {
                    rateDetailInfo.CucFrom02 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtCucFrom03.Text))
                {
                    rateDetailInfo.CucFrom03 = int.Parse(this.txtCucFrom03.Text);
                }
                else
                {
                    rateDetailInfo.CucFrom03 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtCucFrom04.Text))
                {
                    rateDetailInfo.CucFrom04 = int.Parse(this.txtCucFrom04.Text);
                }
                else
                {
                    rateDetailInfo.CucFrom04 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtCucFrom05.Text))
                {
                    rateDetailInfo.CucFrom05 = int.Parse(this.txtCucFrom05.Text);
                }
                else
                {
                    rateDetailInfo.CucFrom05 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtCucFrom06.Text))
                {
                    rateDetailInfo.CucFrom06 = int.Parse(this.txtCucFrom06.Text);
                }
                else
                {
                    rateDetailInfo.CucFrom06 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtCucFrom07.Text))
                {
                    rateDetailInfo.CucFrom07 = int.Parse(this.txtCucFrom07.Text);
                }
                else
                {
                    rateDetailInfo.CucFrom07 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtCucFrom08.Text))
                {
                    rateDetailInfo.CucFrom08 = int.Parse(this.txtCucFrom08.Text);
                }
                else
                {
                    rateDetailInfo.CucFrom08 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtCucFrom09.Text))
                {
                    rateDetailInfo.CucFrom09 = int.Parse(this.txtCucFrom09.Text);
                }
                else
                {
                    rateDetailInfo.CucFrom09 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtCucFrom010.Text))
                {
                    rateDetailInfo.CucFrom10 = int.Parse(this.txtCucFrom010.Text);
                }
                else
                {
                    rateDetailInfo.CucFrom10 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtCucRate01.Text))
                {
                    rateDetailInfo.CucRate01 = decimal.Parse(this.txtCucRate01.Text);
                }
                else
                {
                    rateDetailInfo.CucRate01 = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtCucRate02.Text))
                {
                    rateDetailInfo.CucRate02 = decimal.Parse(this.txtCucRate02.Text);
                }
                else
                {
                    rateDetailInfo.CucRate02 = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtCucRate03.Text))
                {
                    rateDetailInfo.CucRate03 = decimal.Parse(this.txtCucRate03.Text);
                }
                else
                {
                    rateDetailInfo.CucRate03 = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtCucRate04.Text))
                {
                    rateDetailInfo.CucRate04 = decimal.Parse(this.txtCucRate04.Text);
                }
                else
                {
                    rateDetailInfo.CucRate04 = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtCucRate05.Text))
                {
                    rateDetailInfo.CucRate05 = decimal.Parse(this.txtCucRate05.Text);
                }
                else
                {
                    rateDetailInfo.CucRate05 = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtCucRate06.Text))
                {
                    rateDetailInfo.CucRate06 = decimal.Parse(this.txtCucRate06.Text);
                }
                else
                {
                    rateDetailInfo.CucRate06 = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtCucRate07.Text))
                {
                    rateDetailInfo.CucRate07 = decimal.Parse(this.txtCucRate07.Text);
                }
                else
                {
                    rateDetailInfo.CucRate07 = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtCucRate08.Text))
                {
                    rateDetailInfo.CucRate08 = decimal.Parse(this.txtCucRate08.Text);
                }
                else
                {
                    rateDetailInfo.CucRate08 = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtCucRate09.Text))
                {
                    rateDetailInfo.CucRate09 = decimal.Parse(this.txtCucRate09.Text);
                }
                else
                {
                    rateDetailInfo.CucRate09 = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtCucRate010.Text))
                {
                    rateDetailInfo.CucRate10 = decimal.Parse(this.txtCucRate010.Text);
                }
                else
                {
                    rateDetailInfo.CucRate10 = 0M;
                }
                if (!string.IsNullOrEmpty(this.txtCucTo01.Text))
                {
                    rateDetailInfo.CucTo01 = int.Parse(this.txtCucTo01.Text);
                }
                else
                {
                    rateDetailInfo.CucTo01 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtCucTo02.Text))
                {
                    rateDetailInfo.CucTo02 = int.Parse(this.txtCucTo02.Text);
                }
                else
                {
                    rateDetailInfo.CucTo02 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtCucTo03.Text))
                {
                    rateDetailInfo.CucTo03 = int.Parse(this.txtCucTo03.Text);
                }
                else
                {
                    rateDetailInfo.CucTo03 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtCucTo04.Text))
                {
                    rateDetailInfo.CucTo04 = int.Parse(this.txtCucTo04.Text);
                }
                else
                {
                    rateDetailInfo.CucTo04 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtCucTo05.Text))
                {
                    rateDetailInfo.CucTo05 = int.Parse(this.txtCucTo05.Text);
                }
                else
                {
                    rateDetailInfo.CucTo05 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtCucTo06.Text))
                {
                    rateDetailInfo.CucTo06 = int.Parse(this.txtCucTo06.Text);
                }
                else
                {
                    rateDetailInfo.CucTo06 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtCucTo07.Text))
                {
                    rateDetailInfo.CucTo07 = int.Parse(this.txtCucTo07.Text);
                }
                else
                {
                    rateDetailInfo.CucTo07 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtCucTo08.Text))
                {
                    rateDetailInfo.CucTo08 = int.Parse(this.txtCucTo08.Text);
                }
                else
                {
                    rateDetailInfo.CucTo08 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtCucTo09.Text))
                {
                    rateDetailInfo.CucTo09 = int.Parse(this.txtCucTo09.Text);
                }
                else
                {
                    rateDetailInfo.CucTo09 = 0;
                }
                if (!string.IsNullOrEmpty(this.txtCucTo010.Text))
                {
                    rateDetailInfo.CucTo10 = int.Parse(this.txtCucTo010.Text);
                }
                else
                {
                    rateDetailInfo.CucTo10 = 0;
                }
                rateDetailInfo.Udf1 = this.txtUdf1.Text;
                rateDetailInfo.Udf2 = this.txtUdf2.Text;
                rateDetailInfo.Udf3 = this.txtUdf3.Text;
                rateDetailInfo.Udf4 = this.txtUdf4.Text;
                rateDetailInfo.Udf5 = this.txtUdf5.Text;
                rateDetailInfo.Udf6 = this.txtUdf6.Text;
                rateDetailInfo.Udf7 = this.txtUdf7.Text;
                rateDetailInfo.Udf8 = this.txtUdf8.Text;
                rateDetailInfo.Udf9 = this.txtUdf9.Text;
                rateDetailInfo.Udf10 = this.txtUdf10.Text;
                rateDetailInfo.IsActive = this.chkIsActive.Checked ? "Y" : "N";
                rateDetailInfo.UpdatedBy = base.UserInfo.UserID;
                this.lblMsg.Text = BaseInfoDetailServiceClientProxy.GetInstance().UpdateDetail(rateDetailInfo, "RATE_DETAIL") + base.GetGlobalMsgResource("F9150_003");
                this.hdnFlag.Value = "1";
                base.Server.Transfer(string.Format("Rate.aspx?from={0}&detail={1}&ID={2}", base.UrlEncode(this.hdnFrom.Value), "1", base.UrlEncode(this.hdnRateID.Value)));
            }
            catch (Exception ex)
            {
                this.lblMsg.Text = base.GetGlobalMsgResource("F9150_016") + ex.Message;
            }
        }
    }
}

